/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef INTERFACES_TEST_UNITTEST_MOVEDIR_MOCK_MOVEDIR_MOCK_H
#define INTERFACES_TEST_UNITTEST_MOVEDIR_MOCK_MOVEDIR_MOCK_H

#include "n_napi.h"
#include "filemgmt_libn.h"
#include "movedir.h"

#include <cstdio>
#include <filesystem>
#include <gmock/gmock.h>
#include <tuple>

namespace OHOS::FileManagement::ModuleFileIO::Test {
using namespace std::filesystem;
using namespace OHOS::FileManagement::ModuleFileIO;
using namespace OHOS::FileManagement::LibN;

class IMovedirMock {
public:
    virtual ~IMovedirMock() = default;
    virtual bool InitArgs(std::function<bool()> argcChecker) = 0;
    virtual std::tuple<bool, std::unique_ptr<char[]>, size_t> ToUTF8StringPath() = 0;
    virtual std::tuple<bool, int32_t> ToInt32(int32_t defaultValue) = 0;
    virtual size_t GetArgc(void) = 0;
    virtual void ThrowErrAddData(napi_env env, int errCode, napi_value data) = 0;
    virtual napi_status napi_create_array(napi_env env, napi_value *result) = 0;
    virtual void ThrowErr(napi_env env) = 0;
    virtual int stat(const char *path, struct stat *buf) = 0;
};

class MovedirMock : public IMovedirMock {
public:
    MOCK_METHOD(int, stat, (const char *, struct stat *), (override));
    MOCK_METHOD(bool, InitArgs, (std::function<bool()>), (override));
    MOCK_METHOD((std::tuple<bool, std::unique_ptr<char[]>, size_t>), ToUTF8StringPath, (), (override));
    MOCK_METHOD((std::tuple<bool, int32_t>), ToInt32, (int32_t), (override));
    MOCK_METHOD(void, ThrowErrAddData, (napi_env, int, napi_value), (override));
    MOCK_METHOD(size_t, GetArgc, (), (override));
    MOCK_METHOD(void, ThrowErr, (napi_env), (override));
    MOCK_METHOD(napi_status, napi_create_array, (napi_env, napi_value *), (override));

public:
    static std::shared_ptr<MovedirMock> GetMock();
    static void EnableMock();
    static void DisableMock();
    static bool IsMockable();

private:
    static thread_local std::shared_ptr<MovedirMock> movedirMock;
    static thread_local bool mockable;
};

} // namespace OHOS::FileManagement::ModuleFileIO::Test
#endif // INTERFACES_TEST_UNITTEST_MOVEDIR_MOCK_MOVEDIR_MOCK_H